package yang.yu.hrm.organisation.domain;

import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;

/**
 * Created by yyang on 2016/10/7.
 */
@Entity
@DiscriminatorValue("Dept")
public class Department extends OrganizationUnit {
    @Override
    public void createChild(Organization org) {
        if (org instanceof Company) {
            throw new OrganizationCreationException("Cannot create Company under Department");
        }
        org.setParent(this);
        getRepository().save(org);
    }
}
